<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title></title>

    <!-- Bootstrap Core CSS -->
    <link href="/recommendserver/Public/home/css/bootstrap.min.css" rel="stylesheet">
    <link href="/recommendserver/Public/home/css/alert.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <!--<link href="_PUBLIC__/font/css/font-awesome.min.css" rel="stylesheet" type="text/css">-->

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link href="/recommendserver/Public/home/css/common.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid">
    <!-- Page Heading -->
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li class="active">
                    <i class="fa fa-fw fa-edit"></i>
                    组合
                </li>
            </ol>
        </div>
    </div>
    <!-- /.row -->
    <div class="row head">
        <div class="col-lg-12">
            <form action="<?php echo U('Account/index');?>" method="post">
                <div class="input-group form-inline">
                    <select class="form-control" style="width: auto;" name="search_id">
                        <option value="0" <?php if($search_id == 0): ?>selected<?php endif; ?>>请选择店铺</option>
                        <?php if(is_array($store)): $i = 0; $__LIST__ = $store;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sto): $mod = ($i % 2 );++$i;?><option value="<?php echo ($sto["store_id"]); ?>" <?php if($search_id == $sto['store_id']): ?>selected<?php endif; ?>><?php echo ($sto["store_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                    <button class="btn btn-info" type="submit"><span class="glyphicon glyphicon-search"></span></button>
                </span>
                </div>
            </form>

        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <h2></h2>
            <div class="">
                <table class="table table-bordered table-hover table-striped" id="dataTables-date">
                    <thead>
                    <tr>
                        <th>结算单号</th>
                        <th>起止时间</th>
                        <th>订单总额</th>
                        <th>分佣比例</th>
                        <th>本期应收</th>
                        <th>结算状态</th>
                        <th>推广人状态</th>
                        <th>商家状态</th>
                        <th>付款日期</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if(is_array($account)): $i = 0; $__LIST__ = $account;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$acc): $mod = ($i % 2 );++$i;?><tr>
                            <td><?php echo ($acc["account_num"]); ?></td>
                            <td><?php echo (date("Y-m-d",$acc["start_time"])); ?>-<?php echo (date("Y-m-d",$acc["end_time"])); ?></td>
                            <td><?php echo ($acc["money"]); ?></td>
                            <td><?php echo ($acc["sub"]); ?></td>
                            <td><?php echo (round($acc['money'] * $acc['sub'],2)); ?></td>
                            <td><?php echo (get_AccountStatus($acc["state"])); ?></td>
                            <td><?php if($acc["recommend_state"] == 0): ?>未确认<?php elseif($acc["recommend_state"] == 1): ?>已确认<?php else: ?>已拒绝<?php endif; ?></td>
                            <td><?php if($acc["seller_state"] == 0): ?>未确认<?php elseif($acc["seller_state"] == 1): ?>已确认<?php else: ?>已拒绝<?php endif; ?></td>
                            <td><?php if(!empty($acc["pay_time"])): echo (date("Y-m-d H:i",$acc["pay_time"])); endif; if(empty($acc["pay_time"])): ?>无<?php endif; ?></td>
                            <td attr-id="<?php echo ($acc["account_id"]); ?>"><button type="button" class="btn btn-default check">查看订单</button> &nbsp  <button type="button" class="btn btn-default confirm">确认订单</button></td>
                        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- /.row -->
    <div class="pages">
        <?php echo ($page); ?>
    </div>
    <div class = "bg-model" style="position:absolute;top:0%;left:0%;display:none;background:rgba(0,0,0,0.3);width:100%;height:100%;position:fixed;z-index:9999">
        <iframe src="<?php echo U('order/index');?>" id="goods_page" width="90%" height="90%"></iframe>
    </div>


</div>



<script src="/recommendserver/Public/home/js/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="/recommendserver/Public/home/js/bootstrap.min.js"></script>

<script src="/recommendserver/Public/home/js/alert.js"></script>

<!-- iframe自适应高度 -->

</body>
<script type="text/javascript">


    $("button.check").click(function () {
        var id = $(this).parent().attr('attr-id')
        var src = $("iframe").attr('src');
        $("iframe").attr('src',src+'&id='+id)
        console.log($("iframe").attr('src'))
        $("iframe").contents().find(".checkitem:checked");
        $("iframe").contents().find(".checkitem:checked").each(function () {
            $(this).removeAttr('checked');
        })
        $("iframe").contents().items = '';
        $(".bg-model").fadeTo(300,1)
        //隐藏窗体的滚动条
        $("body").css({ "overflow": "hidden" });
    })
    $("button.confirm").click(function () {
        var id = $(this).parent().attr('attr-id')
        var m =jqueryAlert({
            'style'        : 'pc',
            'title'   : '核对',
            'content' : '账单是否无误',
            'modal'   : true,
            'animateType' : '',
            'width' : '400px',
            'buttons' :{
                '确认' : function(){
                    $.ajax({
                        type: "post",
                        url: "<?php echo U('Account/changeAccount');?>",
                        async: true,
                        data: {'recommend_state': '1','id':id},
                        dataType: "json",
                        success: function (result) {
                            if(result.code == 10000){
                                alert('确认成功');
                                location.href = "<?php echo U('Account/index');?>";
                            }
                        }
                    })
                },
                '有误' : function(){
                    $.ajax({
                        type: "post",
                        url: "<?php echo U('Account/changeAccount');?>",
                        async: true,
                        data: {'seller_state': '2','id':id},
                        dataType: "json",
                        success: function (result) {
                            if(result.code == 10000){
                                m.show('确认有误成功');
                                location.href = "<?php echo U('Account/index');?>";
                            }
                        }
                    })
                },
                '取消' : function(){
                    m.close();
                },
            }
        })
    })

</script>

</html>